package com.shop2cn.iapi.agentproducts.testcase;

import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.AgentPriceDto;
import com.shop2cn.iapi.agentproducts.parameter.CatalogDto;
import com.shop2cn.iapi.agentproducts.parameter.FastImportProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ImportAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ModifyAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ModifyCatalogDto;
import com.shop2cn.iapi.agentproducts.service.FastImportProductCall;
import com.shop2cn.iapi.agentproducts.service.ImportAgentProductCall;
import com.shop2cn.iapi.agentproducts.service.ImportAgentProductCallV2;
import com.ymatou.iapi.godmch.parameter.CreateCodeBean;
import com.ymatou.iapi.godmch.parameter.createIndepMchBean;
import com.ymatou.iapi.godmch.service.CreateCodeCall;
import com.ymatou.iapi.godmch.service.createIndepMchCall;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.AgentProductCallService;
import com.ymttest.business.service.ProductManagerCallServiceV3;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.sqlwapper.YmtCatalogsIWapper;
import com.ymttest.database.sqlwapper.YmtProductsIWapper;
import com.ymttest.utils.AgentUsers;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;

/**
 * 导入商品到我的小铺 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_ImportAgentProduct {
	private static ImportAgentProductBean importagentproductBean;
	private static ImportAgentProductCall importagentproductCall;
	// 渠道商
	private static int rootUserId = AgentUsers.rootUserId;
	private static String rootUserName = "NickautoTest";
	// 渠道商->代理商1
	private static int agentUserId1 = AgentUsers.agentUserId1;
	private static String agentUserName1 = "NickautoTest";
	// 渠道商->代理商2
	private static int agentUserId2 = AgentUsers.agentUserId2;
	private static String agentUserName2 = "NickautoTest";

	// vip渠道
	private static int vipRootUserId = AgentUsers.vipRootUserId;
	private static String vipRootUserName = "NickautoTest";
	// vip渠道->代理
	private static int vipAgentUserId1 = AgentUsers.vipAgentUserId1;
	private static String vipAgentUserName1 = "dgsq408897016";
	// vip渠道->代理->代理
	private static int vipAgentUserId2 = AgentUsers.vipAgentUserId2;
	private static String vipAgentUserName2 = "NickautoTest";

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("导入商品到我的小铺");
	}

	@Before
	public void caseUp() {
		importagentproductBean = new ImportAgentProductBean();
		importagentproductCall = new ImportAgentProductCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(importagentproductCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_01() {
		Logger.start(true, "普通代理导入商品，导入成功");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(agentUserId1, agentUserName1, productId, rootUserId, false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject()
					.get("newProductId").getAsString();
			AgentProductCallService.checkImportantAgentProduct(agentProductId, importAgentProductBean, false);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_02() {
		Logger.start(true, "普通代理导入商品，设置代理价，导入成功");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(agentUserId1, agentUserName1, productId, rootUserId, false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject()
					.get("newProductId").getAsString();
			AgentProductCallService.checkImportantAgentProduct(agentProductId, importAgentProductBean, false);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_03() {
		Logger.start(true, "vip代理导入vip渠道商商品，导入成功");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, true);

			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject()
					.get("newProductId").getAsString();
			AgentProductCallService.checkImportantAgentProduct(agentProductId, importAgentProductBean, true);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_04() {
		Logger.start(true, "vip代理导入vip渠道商商品，设置代理价格列表，导入成功");
		try {

			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, true);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject()
					.get("newProductId").getAsString();
			AgentProductCallService.checkImportantAgentProduct(agentProductId, importAgentProductBean, true);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_05() {
		Logger.start(true, "vip代理导入vip代理商品，导入成功");
		try {

			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, true);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject()
					.get("newProductId").getAsString();
			AgentProductCallService.checkImportantAgentProduct(agentProductId, importAgentProductBean, true);

			ImportAgentProductBean importAgentProductBean1 = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId2, vipAgentUserName2, agentProductId, vipAgentUserId1, false);
			importagentproductCall.setData(importAgentProductBean1);
			importagentproductCall.callService();
			String agentProductId1 = importagentproductCall.getJsonObject().get("data").getAsJsonObject()
					.get("newProductId").getAsString();
			AgentProductCallService.checkImportantAgentProduct(agentProductId1, importAgentProductBean1, true);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_06() {
		Logger.start(true, "代理商导入无效商品，导入失败");
		try {
			importagentproductBean.setUserId(agentUserId1);
			importagentproductBean.setUserName(agentUserName1);
			importagentproductBean.setTitle("导入测试商品" + TestDataManager.getRandomNum(6));
			List<String> picList = new ArrayList<>();
			picList.add(
					"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
			picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
			picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
			importagentproductBean.setPics(picList);
			importagentproductBean.setRemark("测试商品");
			importagentproductBean.setParentUserId(rootUserId);
			importagentproductBean.setParentProductId("1111");

			List<CatalogDto> catalogDtos = new ArrayList<>();
			CatalogDto catalogDto1 = new CatalogDto();
			catalogDto1.setParentCatalogId("111");
			catalogDto1.setDirectPrice(100d);
			catalogDto1.setStock(100);
			catalogDto1.setSku("123456");
			catalogDto1.setPropertyValue("hello，world");
			List<AgentPriceDto> agentPrice = new ArrayList<>();

			AgentPriceDto agentPriceDto1 = new AgentPriceDto();
			agentPriceDto1.setAgentTypeId(1);
			agentPriceDto1.setAgentPrice(110);
			agentPrice.add(agentPriceDto1);

			AgentPriceDto agentPriceDto2 = new AgentPriceDto();
			agentPriceDto2.setAgentTypeId(2);
			agentPriceDto2.setAgentPrice(120);
			agentPrice.add(agentPriceDto2);

			catalogDto1.setAgentPriceList(agentPrice);
			catalogDtos.add(catalogDto1);

			CatalogDto catalogDto2 = new CatalogDto();
			catalogDto2.setParentCatalogId("222");
			catalogDto2.setDirectPrice(100d);
			catalogDto2.setStock(100);
			catalogDto2.setSku("123456");
			catalogDto2.setPropertyValue("hello，world");
			List<AgentPriceDto> agentPrice1 = new ArrayList<>();
			AgentPriceDto agentPriceDto3 = new AgentPriceDto();
			agentPriceDto3.setAgentTypeId(1);
			agentPriceDto3.setAgentPrice(130);
			agentPrice1.add(agentPriceDto3);
			AgentPriceDto agentPriceDto4 = new AgentPriceDto();
			agentPriceDto4.setAgentTypeId(2);
			agentPriceDto4.setAgentPrice(140);
			agentPrice1.add(agentPriceDto4);
			catalogDto2.setAgentPriceList(agentPrice1);
			catalogDtos.add(catalogDto2);

			importagentproductBean.setCatalogList(catalogDtos);
			importagentproductCall.setData(importagentproductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("201", importagentproductCall.getString("code"), "验证Code");
			Logger.verifyEquals("商品不存在", importagentproductCall.getString("message"), "验证Message");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_07() {
		Logger.start(true, "代理商导入商品，无效规格，导入失败");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, false);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			importagentproductBean.setUserId(agentUserId1);
			importagentproductBean.setUserName(agentUserName1);
			importagentproductBean.setTitle("导入测试商品" + TestDataManager.getRandomNum(6));
			List<String> picList = new ArrayList<>();
			picList.add(
					"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
			picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
			picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
			importagentproductBean.setPics(picList);
			importagentproductBean.setRemark("测试商品");
			importagentproductBean.setParentUserId(rootUserId);
			importagentproductBean.setParentProductId(productId);

			List<CatalogDto> catalogDtos = new ArrayList<>();
			CatalogDto catalogDto1 = new CatalogDto();
			catalogDto1.setParentCatalogId("111");
			catalogDto1.setDirectPrice(100d);
			catalogDto1.setStock(100);
			catalogDto1.setSku("123456");
			catalogDto1.setPropertyValue("hello，world");
			List<AgentPriceDto> agentPrice = new ArrayList<>();
			AgentPriceDto agentPriceDto2 = new AgentPriceDto();
			agentPriceDto2.setAgentTypeId(2);
			agentPriceDto2.setAgentPrice(120);
			agentPrice.add(agentPriceDto2);

			catalogDto1.setAgentPriceList(agentPrice);
			catalogDtos.add(catalogDto1);
			CatalogDto catalogDto2 = new CatalogDto();
			catalogDto2.setParentCatalogId("222");
			catalogDto2.setDirectPrice(100d);
			catalogDto2.setStock(100);
			catalogDto2.setSku("123456");
			catalogDto2.setPropertyValue("hello，world");
			List<AgentPriceDto> agentPrice1 = new ArrayList<>();
			AgentPriceDto agentPriceDto4 = new AgentPriceDto();
			agentPriceDto4.setAgentTypeId(2);
			agentPriceDto4.setAgentPrice(140);
			agentPrice1.add(agentPriceDto4);
			catalogDto2.setAgentPriceList(agentPrice1);
			catalogDtos.add(catalogDto2);

			importagentproductBean.setCatalogList(catalogDtos);
			importagentproductCall.setData(importagentproductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("201", importagentproductCall.getString("code"), "验证Code");
			Logger.verifyEquals("商品不存在", importagentproductCall.getString("message"), "验证Message");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	public void Tc_ImportAgentProduct_08() {
		Logger.start(true, "代理商导入渠道商保存商品，导入失败");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			agentProductBean.setSaleType(2);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("201", importagentproductCall.getString("code"), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	public void Tc_ImportAgentProduct_09() {
		Logger.start(true, "代理商导入库存为0商品，导入失败");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, false);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			new YmtCatalogsIWapper().updatestocknumByProductID(0, productId);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("201", importagentproductCall.getString("code"), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_10() {
		Logger.start(true, "代理商导入商品，直销价小于上级给的代理价，导入失败");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, true);
			importAgentProductBean.getCatalogList().get(0).setDirectPrice(50d);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("201", importagentproductCall.getString("code"), "验证Code");
			Logger.verifyEquals("代理价不能高于直销价高", importagentproductCall.getString("message"), "验证message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_11() {
		Logger.start(true, "代理商导入商品，代理价小于上级给的代理价，导入失败");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, true);
			Logger.debug(importAgentProductBean);
			importAgentProductBean.getCatalogList().get(0).getAgentPriceList().get(0).setAgentPrice(10);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("201", importagentproductCall.getString("code"), "验证Code");
			Logger.verifyEquals("下级代理价需高于拿到的代理价", importagentproductCall.getString("message"), "验证message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_12() {
		Logger.start(true, "代理商导入商品，商品图片小于1张，导入失败");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, false);
			importAgentProductBean.setPics(null);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("400", importagentproductCall.getString("code"), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_13() {
		Logger.start(true, "代理商导入商品，商品图片大于8张，导入失败");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, false);
			List<String> picList = new ArrayList<>();
			for (int i = 0; i < 9; i++) {
				picList.add(
						"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
			}
			importAgentProductBean.setPics(picList);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("201", importagentproductCall.getString("code"), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_14() {
		Logger.start(true, "代理商导入商品，标题超过500字符，导入失败");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, false);
			String tite = "1";
			for (int i = 0; i < 501; i++) {
				tite = tite + "1";
			}
			importAgentProductBean.setTitle(tite);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("400", importagentproductCall.getString("code"), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_15() {
		Logger.start(true, "代理商导入商品，标题为空，导入失败");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, false);
			importAgentProductBean.setTitle(null);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("400", importagentproductCall.getString("code"), "验证Code");
			Logger.verifyEquals("title:商品标题不能为空", importagentproductCall.getString("message"), "验证Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	public void Tc_ImportAgentProduct_16() {
		Logger.start(true, "代理商导入商品，备注超过700字符，导入失败");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, false);
			String remark = "1";
			for (int i = 0; i < 701; i++) {
				remark = remark + "1";
			}
			importAgentProductBean.setRemark(remark);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("400", importagentproductCall.getString("code"), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_17() {
		Logger.start(true, "代理商导入商品，上级商户不存在，导入失败");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, 111, false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("201", importagentproductCall.getString("code"), "验证Code");
			Logger.verifyEquals("商户关系错误，操作失败", importagentproductCall.getString("message"), "验证Message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_18() {
		Logger.start(true, "	");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, false);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(1, "1",
					productId, vipRootUserId, false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			// Logger.verifyEquals("500",importagentproductCall.getString("code"),"验证code");
			Logger.verifyEquals("201", importagentproductCall.getString("code"), "验证code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_19() {
		Logger.start(true, "代理商导入已经删除商品，导入失败");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, false);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			AddAgentProductCallService.DeleteProduct(productId, vipRootUserId);
			importagentproductBean.setParentProductId(productId);
			importagentproductBean.setUserId(vipAgentUserId1);
			importagentproductBean.setUserName(vipAgentUserName1);
			importagentproductBean.setParentUserId(vipRootUserId);
			importagentproductBean.setTitle("jwi");
			List<String> picList = new ArrayList<>();
			picList.add(
					"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
			picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
			picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
			// 商品图片
			importagentproductBean.setPics(picList);
			importagentproductCall.setData(importagentproductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("400", importagentproductCall.getString("code"), "验证code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_20() {
		Logger.start(true, "代理商导入码头商品，导入失败");
		try {
			int sellerId = Integer.parseInt(EnvSetup.getData("productsellerid"));
			AddSellerProductRequest addpro = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			importagentproductBean.setUserId(vipAgentUserId1);
			importagentproductBean.setParentUserId(rootUserId);
			importagentproductBean.setTitle("111");
			importagentproductBean.setUserName(vipAgentUserName1);
			importagentproductBean.setParentProductId(productId);
			importagentproductBean.setSetAgentPrice(false);
			importagentproductCall.setData(importagentproductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("400", importagentproductCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_21() {
		Logger.start(true, "代理商导入同级代理商商品，导入失败");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(agentUserId1, agentUserName1, productId, rootUserId, false);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
			importAgentProductBean.setUserId(agentUserId2);
			importAgentProductBean.setUserName(agentUserName2);
			importAgentProductBean.setTitle("导入测试商品" + TestDataManager.getRandomNum(6));
			List<String> picList = new ArrayList<>();
			picList.add(
					"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
			picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
			picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
			importAgentProductBean.setPics(picList);
			importAgentProductBean.setRemark("测试商品");
			importAgentProductBean.setParentUserId(agentUserId1);
			importAgentProductBean.setParentProductId(agentProductId);
			importAgentProductBean.setSetAgentPrice(false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("201", importagentproductCall.getString("code"), "验证code");
			Logger.verifyEquals("错误的商品类型AENT_TYPE:NORMAL，无法导入此商品", importagentproductCall.getString("message"),
					"验证message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_22() {
		Logger.start(true, "代理商导入商品，商品未开启代理权限，导入失败");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, false);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = new ImportAgentProductBean();
			importAgentProductBean.setUserId(agentUserId2);
			importAgentProductBean.setUserName(agentUserName2);
			importAgentProductBean.setTitle("导入测试商品" + TestDataManager.getRandomNum(6));
			List<String> picList = new ArrayList<>();
			picList.add(
					"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
			picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
			picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
			importAgentProductBean.setPics(picList);
			importAgentProductBean.setRemark("测试商品");
			importAgentProductBean.setParentUserId(rootUserId);
			importAgentProductBean.setParentProductId(productId);
			importAgentProductBean.setSetAgentPrice(false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("400", importagentproductCall.getString("code"), "验证code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_23() {
		Logger.start(true, "代理商导入商品，商品信息未完善，导入失败");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
			ymtProductsIWapper.updateAgentProductInfoProgress(productId, -1);
			ImportAgentProductBean importAgentProductBean = new ImportAgentProductBean();
			importAgentProductBean.setUserId(agentUserId2);
			importAgentProductBean.setUserName(agentUserName2);
			importAgentProductBean.setTitle("导入测试商品" + TestDataManager.getRandomNum(6));
			List<String> picList = new ArrayList<>();
			picList.add(
					"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
			picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
			picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
			importAgentProductBean.setPics(picList);
			importAgentProductBean.setRemark("测试商品");
			importAgentProductBean.setParentUserId(rootUserId);
			importAgentProductBean.setParentProductId(productId);
			importAgentProductBean.setSetAgentPrice(false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("400", importagentproductCall.getString("code"), "验证code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_24() {
		Logger.start(true, "代理商导入商品，商品价格信息未完善，导入失败");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
			ymtProductsIWapper.updateAgentProductInfoProgress(productId, -2);
			ImportAgentProductBean importAgentProductBean = new ImportAgentProductBean();
			importAgentProductBean.setUserId(agentUserId2);
			importAgentProductBean.setUserName(agentUserName2);
			importAgentProductBean.setTitle("导入测试商品" + TestDataManager.getRandomNum(6));
			List<String> picList = new ArrayList<>();
			picList.add(
					"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
			picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
			picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
			importAgentProductBean.setPics(picList);
			importAgentProductBean.setRemark("测试商品");
			importAgentProductBean.setParentUserId(rootUserId);
			importAgentProductBean.setParentProductId(productId);
			importAgentProductBean.setSetAgentPrice(false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("400", importagentproductCall.getString("code"), "验证code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_25() {
		Logger.start(true, "代理商导入已经导入的商品，导入失败");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(agentUserId1, agentUserName1, productId, rootUserId, false);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
			importAgentProductBean.setUserId(agentUserId1);
			importAgentProductBean.setUserName(agentUserName1);
			importAgentProductBean.setTitle("导入测试商品" + TestDataManager.getRandomNum(6));
			List<String> picList = new ArrayList<>();
			picList.add(
					"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
			picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
			picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
			importAgentProductBean.setPics(picList);
			importAgentProductBean.setRemark("测试商品");
			importAgentProductBean.setParentUserId(rootUserId);
			importAgentProductBean.setParentProductId(productId);
			importAgentProductBean.setSetAgentPrice(false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("201", importagentproductCall.getString("code"), "验证code");
			Logger.verifyEquals("已代理的商品不能重复代理，操作失败", importagentproductCall.getString("message"), "验证message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_26() {
		Logger.start(true, "代理商导入商品，直销价为0,导入失败");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(agentUserId1, agentUserName1, productId, rootUserId, false);
			importAgentProductBean.getCatalogList().get(0).setDirectPrice(0d);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("201", importagentproductCall.getString("code"), "验证code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_28() {
		Logger.start(true, "普通渠道商新增规格，新增规格无代理价,导入成功");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			ModifyAgentProductBean modifyagentproductBean = AddAgentProductCallService
					.initModifyAgentProductBean(productId, addAgentProductBean);
			// 新增规格
			ModifyCatalogDto catalogDto = new ModifyCatalogDto();
			catalogDto.setDirectPrice(110);
			catalogDto.setStock(110);
			catalogDto.setSku(modifyagentproductBean.getCatalogList().get(0).getSku());
			catalogDto.setOperateType(0);
			String name = "新增规格" + TestDataManager.getRandomNum(6);
			catalogDto.setPropertyValue(name);
			catalogDto.setAgentPriceList(null);
			modifyagentproductBean.getCatalogList().add(catalogDto);

			AddAgentProductCallService.modifyAgentProduct(modifyagentproductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(agentUserId1, agentUserName1, productId, rootUserId, false);

			YmtCatalogsIWapper ymtCatalogsIWapper = new YmtCatalogsIWapper();
			ymtCatalogsIWapper.selectCatalogsByProductId(productId).forEach(p -> {
				if (p.getfQuotePrice().doubleValue() == 110) {
					String catalogId = p.getsCatalogId();
					importAgentProductBean.getCatalogList().get(2)
							.setDirectPrice(p.getfQuotePrice().doubleValue() + 100);
					importAgentProductBean.getCatalogList().get(2).setSku(p.getsSKU());
					importAgentProductBean.getCatalogList().get(2).setParentCatalogId(catalogId);
					importAgentProductBean.getCatalogList().get(2).setStock(p.getiNum());
					importAgentProductBean.getCatalogList().get(2).setPropertyValue(name);
				}
			});

			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("200", importagentproductCall.getString("code"), "验证code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_281() {
		Logger.start(true, "渠道商，规格无代理价,代理商导入成功");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, false);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			importagentproductBean = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId1,
					vipAgentUserName1, productId, vipRootUserId, false);

			importagentproductCall.setData(importagentproductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("200", importagentproductCall.getString("code"), "验证code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_282() {
		Logger.start(true, "vip渠道->vip1->vip2,vip1没有设置下级代理，VIP2导入vip1的商品,导入成功");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			importagentproductBean = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId1,
					vipAgentUserName1, productId, vipRootUserId, false);

			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importagentproductBean);

			importagentproductBean = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId2,
					vipAgentUserName2, agentProductId, vipAgentUserId1, false);

			importagentproductCall.setData(importagentproductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("200", importagentproductCall.getString("code"), "验证code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_29() {
		Logger.start(true, "商品代理连超过6级，导入失败");
		try {
			int vipRootUserId1 = 500009705;
			int vipUserId1 = 500009740;
			int vipUserId2 = 500009741;
			int vipUserId3 = 500009742;
			int vipUserId4 = 500009743;
			int vipUserId5 = 500009744;
			int vipUserId6 = 500009745;
			int vipUserId7 = 500009803;
			String name = "NickautoTest";
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId1,
					name, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipUserId1, name, productId, vipRootUserId1, true);
			String productId1 = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);

			ImportAgentProductBean importAgentProductBean1 = AddAgentProductCallService
					.initImportAgentProduct(vipUserId2, name, productId1, vipUserId1, true);
			String productId2 = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean1);

			ImportAgentProductBean importAgentProductBean2 = AddAgentProductCallService
					.initImportAgentProduct(vipUserId3, name, productId2, vipUserId2, true);
			String productId3 = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean2);

			ImportAgentProductBean importAgentProductBean3 = AddAgentProductCallService
					.initImportAgentProduct(vipUserId4, name, productId3, vipUserId3, true);
			String productId4 = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean3);

			ImportAgentProductBean importAgentProductBean4 = AddAgentProductCallService
					.initImportAgentProduct(vipUserId5, name, productId4, vipUserId4, true);
			String productId5 = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean4);

			ImportAgentProductBean importAgentProductBean5 = AddAgentProductCallService
					.initImportAgentProduct(vipUserId6, name, productId5, vipUserId5, true);
			importagentproductCall.setData(importAgentProductBean5);
			importagentproductCall.callService();
			Logger.verifyEquals("201", importagentproductCall.getString("code"), "验证code");
			Logger.verifyEquals("代理链过长，无法继续代理此商品", importagentproductCall.getString("message"), "验证message");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_30() {
		Logger.start(true, "代理商导入下级代理商商品，导入失败");
		try {
			int vipRootUserId1 = 500009705;
			int vipUserId1 = 500009740;
			int vipUserId2 = 500009741;
			String name = "NickautoTest";
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId1,
					name, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipUserId1, name, productId, vipRootUserId1, true);
			String productId1 = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);

			ImportAgentProductBean importAgentProductBean1 = AddAgentProductCallService
					.initImportAgentProduct(vipUserId2, name, productId1, vipUserId1, true);
			String productId2 = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean1);

			ImportAgentProductBean importAgentProductBean5 = AddAgentProductCallService
					.initImportAgentProduct(vipUserId1, name, productId2, vipUserId2, true);
			importagentproductCall.setData(importAgentProductBean5);
			importagentproductCall.callService();
			Logger.verifyEquals("500", importagentproductCall.getString("code"), "验证code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_32() {
		Logger.start(true, "代理商客服导入商品，templateId6，导入失败");
		try {
			int csid = 500028918;
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, true);
			importAgentProductBean.setUserId(csid);
			ImportAgentProductCallV2 importAgentProductCallV2 = new ImportAgentProductCallV2();
			importAgentProductCallV2.setData(importAgentProductBean);
			importAgentProductCallV2.addHeader("ymt-pars",
					"accesstoken=FCD279E177169DBC07B81F1324B12582E11D0A2C48899B1B96AD63B1159A921BA1FF397A27188E27ECBD6B278EAB12F437EAD6743A323249");
			importAgentProductCallV2.callService();
			Logger.verifyEquals("201", importAgentProductCallV2.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_33() {
		Logger.start(true, "导入商品，日本货币，直销价小数点后有数字，导入失败");
		try {
			int rootId = 500060254;
			int agentId = 500060255;

			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootId,
					vipRootUserName, true);
			addAgentProductBean.getCatalogList().forEach(p -> {
				p.setDirectPrice(3000d);
				p.getAgentPriceList().forEach(x -> {
					x.setAgentPrice(2500);
				});
			});
			addAgentProductBean.setCurrency("JPY");
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentId,
					agentUserName1, productId, rootId, false);
			importAgentProductBean.getCatalogList().forEach(p -> {
				p.setDirectPrice(3500.01);
			});
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("201", importagentproductCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_34() {
		Logger.start(true, "代理商导入带视频的商品，导入成功");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			agentProductBean = AddAgentProductCallService.initVideo(agentProductBean);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);

			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("200", importagentproductCall.getString("code"), "验证Code");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_35() {
		Logger.start(true, "代理商导入商品后，添加视频");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			// agentProductBean =
			// AddAgentProductCallService.initVideo(agentProductBean);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);

			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("200", importagentproductCall.getString("code"), "验证Code");
			String newProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject()
					.get("newProductId").toString().replace("\"", "");

			// ProductDetailsBean initGetProductDetails =
			// AddAgentProductCallService.initGetProductDetails(vipAgentUserId1,
			// vipAgentUserId1, newProductId, true);
			// JsonObject get =
			// AddAgentProductCallService.GetProductDetailsJson(initGetProductDetails);
			// Logger.verifyEquals("200", get.get("code"), "判断返回值");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_38() {
		Logger.start(true, "代理商导入商品后，添加视频");
		try {

			rootUserId = 500652989;
			agentUserId1 = 500652990;
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(agentUserId1, agentUserName1, productId, rootUserId, false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject()
					.get("newProductId").getAsString();
			AgentProductCallService.checkImportantAgentProduct(agentProductId, importAgentProductBean, false);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_36() {
		Logger.start(true, "代理商导入商品后，查询");
		try {
			AddAgentProductBean agentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,
					vipRootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(agentProductBean);
			
			// Thread.sleep(5000);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(vipAgentUserId1, vipAgentUserName1, productId, vipRootUserId, false);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			Logger.verifyEquals("200", importagentproductCall.getString("code"), "验证Code");
			String newProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject()
					.get("newProductId").getAsString();
			Thread.sleep(5000);
			FastImportProductCall fpc = new FastImportProductCall();
			FastImportProductBean b = new FastImportProductBean();
			// GetProductListBySellerIdCall gbc=new
			// GetProductListBySellerIdCall();
			// GetProductListBySellerIdBean b=new
			// GetProductListBySellerIdBean();
			// b.setPageIndex(1);
			// b.setPageSize(50);
			// b.setSellerId(vipAgentUserId1);
			// gbc.setData(b);
			// gbc.callService();

			// GetProductListByProductIdListCall gbc=new
			// GetProductListByProductIdListCall();
			// GetProductListByProductIdListBean b=new
			// GetProductListByProductIdListBean();
			// b.setProductIdList(Arrays.asList(newProductId));
			// gbc.setData(b);
			// gbc.callService();
			// System.out.println(newProductId);
			// GetProductInfoByProductIdCall gbc=new
			// GetProductInfoByProductIdCall();
			// GetProductInfoByProductIdBean b=new
			// GetProductInfoByProductIdBean();
			// b.setProductId(newProductId);
			// gbc.setData(b);
			// gbc.callService();
			// System.out.println(gbc.getJsonObject());
			// List<Map> products = new
			// YmtProductsIWapper().selectProductByProductIdforMap(productId);
			// products.forEach(b->{
			// System.out.println(b);
			//// });
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_37() {
		Logger.start(true, "普通代理导入商品，设置市场价，导入成功");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,
					rootUserName, true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService
					.initImportAgentProduct(agentUserId1, agentUserName1, productId, rootUserId, false);
			importAgentProductBean.getCatalogList().get(0).setMarketAmount(1000.00);
			importagentproductCall.setData(importAgentProductBean);
			importagentproductCall.callService();
			String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject()
					.get("newProductId").getAsString();
			AgentProductCallService.checkImportantAgentProduct(agentProductId, importAgentProductBean, false);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ImportAgentProduct_39() {
		Logger.start(true, "普通代理导入商品，设置市场价，导入成功");
		try {
//			500476503--500802481
			createIndepMchBean initCreateIndepMchBean = GodmchManageCallService.InitCreateIndepMchBean();
			createIndepMchCall createIndepMchCall = GodmchManageCallService.CreateIndepMchCall(initCreateIndepMchBean);
			CreateCodeBean bean = GodmchManageCallService.InitcreateCodeBeanForAgent(createIndepMchCall.getmchId(), true);
			// 创建渠道商邀请码
			CreateCodeCall createCodeCall2 = GodmchManageCallService.createCodeCall(bean);
			// 创建代理商
			Integer agentUserId = GodmchManageCallService.CreateSellerMch(
					createCodeCall2.getJsonObject().getAsJsonObject("result").get("code").getAsString());
			int rootUserId = bean.getMchId();

			System.out.println(agentUserId);
			System.out.println(rootUserId);
			
			 AddAgentProductBean addAgentProductBean =
			 AddAgentProductCallService.initAddAgentProduct(rootUserId,rootUserName,true);
			 String productId =
			 AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			 ImportAgentProductBean importAgentProductBean =
			 AddAgentProductCallService.initImportAgentProduct(agentUserId,agentUserName1,productId,rootUserId,false);
			 importAgentProductBean.getCatalogList().get(0).setMarketAmount(1000.00);
			 importagentproductCall.setData(importAgentProductBean);
			 importagentproductCall.callService();
			 String agentProductId = importagentproductCall.getJsonObject().get("data").getAsJsonObject().get("newProductId").getAsString();
			 AgentProductCallService.checkImportantAgentProduct(agentProductId,importAgentProductBean,true);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

}